/*
 * Copyright (c) 2015 www.smarthome.com All rights reserved. 本软件源代码版权归----所有,未经许可不得任意复制与传播.
 */
package com.smarthome.base.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.smarthome.base.dao.ShUserRoleDao;
import com.smarthome.base.dao.base.BaseDaoImpl;
import com.smarthome.domain.bean.ShUserRole;

/**
 * ShUserRoleDao 实现类
 * @author KongXiangyu
 * @since 2015-09-07
 */
@Repository("shUserRoleDao")
public class ShUserRoleDaoImpl extends BaseDaoImpl<ShUserRole, Long> implements ShUserRoleDao {

    private final static String NAMESPACE = "com.smarthome.base.dao.ShUserRoleDao.";

    // 返回本DAO命名空间,并添加statement
    public String getNameSpace(String statement) {
        return NAMESPACE + statement;
    }

    @Override
    public List<ShUserRole> queryUserRolesByUserId(Long userId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("orderField", "sort_weight");
        map.put("orderFieldType", "ASC");
        map.put("userId", userId);
        return this.selectList(getNameSpace("queryUserRolesByUserId"), map);
    }

	@Override
	public ShUserRole queryUserRoleRootByResidenceId(Long residenceId) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("residenceId", residenceId );
		return this.select(getNameSpace("queryUserRoleRootByResidenceId"), map);
	}

	/* (non-Javadoc)
	 * @see com.smarthome.base.dao.ShUserRoleDao#queryShUserRolesByResidenceId(java.lang.Long)
	 */
	@Override
	public List<ShUserRole> queryShUserRolesByResidenceId(Long residenceId) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("residenceId", residenceId);
		return this.selectList(getNameSpace("queryShUserRolesByResidenceId"),map);
	}

	/* (non-Javadoc)
	 * @see com.smarthome.base.dao.ShUserRoleDao#queryUserRoleRootByResidenceId(java.lang.Long[])
	 */
	@Override
	public List<ShUserRole> queryUserRoleRootByResidenceId(Long... residenceId) {
		return this.selectList(getNameSpace("queryUserRolesRootByResidenceId"), residenceId);
	}
}